<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   15个初学者必看的基础SQL查询语句  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/15872.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466459592: Accept with keywords: (title(0.0):语句,社区,基础,初学者,数盟, topn(0.3):社区,基础,标量,数盟,行业资讯,初学者,子句,数据挖掘,过程,表达式,数据分析,结果,人工智能,数据库,职业规划,视图,例子,基础架构,文章,可视化,数据,基本,函数,记录,数据表,语句,编程语言,代码,字段,行业).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    15个初学者必看的基础SQL查询语句
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    15个初学者必看的基础SQL查询语句 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,65] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/base">
       基础架构
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/15872.html">
          15个初学者必看的基础SQL查询语句
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          2,138 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/base" rel="category tag">
          基础架构
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        本文将分享15个初学者必看的基础SQL查询语句，都很基础，但是你不一定都会，所以好好看看吧。
       </p>
       <h2>
        1、创建表和数据插入SQL
       </h2>
       <p>
        我们在开始创建数据表和向表中插入演示数据之前，我想给大家解释一下实时数据表的设计理念，这样也许能帮助大家能更好的理解SQL查询。
       </p>
       <p>
        在数据库设计中，有一条非常重要的规则就是要正确建立主键和外键的关系。
       </p>
       <p>
        现在我们来创建几个餐厅订单管理的数据表，一共用到3张数据表，Item Master表、Order Master表和Order Detail表。
       </p>
       <p>
        <strong>
         创建表：
        </strong>
       </p>
       <p>
        <strong>
         创建Item Master表：
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed3c7455986049" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE TABLE [dbo].[ItemMasters](
	[Item_Code] [varchar](20) NOT NULL,
	[Item_Name] [varchar](100) NOT NULL,
	[Price]  Int NOT NULL,
	[TAX1]  Int NOT NULL,
	[Discount]  Int NOT NULL,
	[Description] [varchar](200) NOT NULL,
	[IN_DATE] [datetime] NOT NULL,
	[IN_USR_ID] [varchar](20) NOT NULL,
	[UP_DATE] [datetime] NOT NULL,
	[UP_USR_ID] [varchar](20) NOT NULL,
 CONSTRAINT [PK_ItemMasters] PRIMARY KEY CLUSTERED 
(
	[Item_Code] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3c7455986049-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3c7455986049-16">
               16
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-1">
               <span class="crayon-st">
                CREATE
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                TABLE
               </span>
               <span class="crayon-h">
               </span>
               [dbo].[ItemMasters](
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-2">
               <span class="crayon-h">
               </span>
               [Item_Code]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-3">
               <span class="crayon-h">
               </span>
               [Item_Name]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](100)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-4">
               <span class="crayon-h">
               </span>
               [Price]
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                Int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-5">
               <span class="crayon-h">
               </span>
               [TAX1]
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                Int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-6">
               <span class="crayon-h">
               </span>
               [Discount]
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                Int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-7">
               <span class="crayon-h">
               </span>
               [Description]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](200)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-8">
               <span class="crayon-h">
               </span>
               [IN_DATE]
               <span class="crayon-h">
               </span>
               [datetime]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-9">
               <span class="crayon-h">
               </span>
               [IN_USR_ID]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-10">
               <span class="crayon-h">
               </span>
               [UP_DATE]
               <span class="crayon-h">
               </span>
               [datetime]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-11">
               <span class="crayon-h">
               </span>
               [UP_USR_ID]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                CONSTRAINT
               </span>
               <span class="crayon-h">
               </span>
               [PK_ItemMasters]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                PRIMARY
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                KEY
               </span>
               <span class="crayon-h">
               </span>
               CLUSTERED
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-13">
               (
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-14">
               <span class="crayon-h">
               </span>
               [Item_Code]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ASC
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3c7455986049-15">
               )
               <span class="crayon-st">
                WITH
               </span>
               <span class="crayon-h">
               </span>
               (PAD_INDEX
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               STATISTICS_NORECOMPUTE
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               IGNORE_DUP_KEY
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               ALLOW_ROW_LOCKS
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               ,
               <span class="crayon-h">
               </span>
               ALLOW_PAGE_LOCKS
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-r">
                PRIMARY
               </span>
               ]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3c7455986049-16">
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-r">
                PRIMARY
               </span>
               ]
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0116 seconds] -->
       <p>
        <strong>
         向Item Master表插入数据：
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed3d9475131505" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          INSERT INTO [ItemMasters]   ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
           ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('Item001','Coke',55,1,0,'Coke which need to be cold',GETDATE(),'SHANU'
           ,GETDATE(),'SHANU')

INSERT INTO [ItemMasters]   ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
           ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('Item002','Coffee',40,0,2,'Coffe Might be Hot or Cold user choice',GETDATE(),'SHANU'
           ,GETDATE(),'SHANU')

INSERT INTO [ItemMasters]   ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
           ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('Item003','Chiken Burger',125,2,5,'Spicy',GETDATE(),'SHANU'
           ,GETDATE(),'SHANU')

INSERT INTO [ItemMasters]   ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
           ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('Item004','Potato Fry',15,0,0,'No Comments',GETDATE(),'SHANU'
           ,GETDATE(),'SHANU')
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3d9475131505-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3d9475131505-23">
               23
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-1">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [ItemMasters]
               <span class="crayon-h">
               </span>
               ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-2">
               <span class="crayon-h">
               </span>
               ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-4">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Item001'
               </span>
               ,
               <span class="crayon-s">
                'Coke'
               </span>
               ,55,1,0,
               <span class="crayon-s">
                'Coke which need to be cold'
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-5">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-6">
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-7">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [ItemMasters]
               <span class="crayon-h">
               </span>
               ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-8">
               <span class="crayon-h">
               </span>
               ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-10">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Item002'
               </span>
               ,
               <span class="crayon-s">
                'Coffee'
               </span>
               ,40,0,2,
               <span class="crayon-s">
                'Coffe Might be Hot or Cold user choice'
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-11">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-12">
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-13">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [ItemMasters]
               <span class="crayon-h">
               </span>
               ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-14">
               <span class="crayon-h">
               </span>
               ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-16">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Item003'
               </span>
               ,
               <span class="crayon-s">
                'Chiken Burger'
               </span>
               ,125,2,5,
               <span class="crayon-s">
                'Spicy'
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-17">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-18">
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-19">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [ItemMasters]
               <span class="crayon-h">
               </span>
               ([Item_Code],[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-20">
               <span class="crayon-h">
               </span>
               ,[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-21">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3d9475131505-22">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Item004'
               </span>
               ,
               <span class="crayon-s">
                'Potato Fry'
               </span>
               ,15,0,0,
               <span class="crayon-s">
                'No Comments'
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3d9475131505-23">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0097 seconds] -->
       <p>
        <strong>
         创建Order Master表：
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed3e6662721728" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE TABLE [dbo].[OrderMasters](
	[Order_No] [varchar](20) NOT NULL,
	[Table_ID] [varchar](20) NOT NULL,
	[Description] [varchar](200) NOT NULL,
	[IN_DATE] [datetime] NOT NULL,
	[IN_USR_ID] [varchar](20) NOT NULL,
	[UP_DATE] [datetime] NOT NULL,
	[UP_USR_ID] [varchar](20) NOT NULL,
 CONSTRAINT [PK_OrderMasters] PRIMARY KEY CLUSTERED 
(
	[Order_No] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed3e6662721728-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3e6662721728-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3e6662721728-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3e6662721728-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3e6662721728-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3e6662721728-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3e6662721728-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3e6662721728-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3e6662721728-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3e6662721728-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3e6662721728-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3e6662721728-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3e6662721728-13">
               13
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed3e6662721728-1">
               <span class="crayon-st">
                CREATE
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                TABLE
               </span>
               <span class="crayon-h">
               </span>
               [dbo].[OrderMasters](
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3e6662721728-2">
               <span class="crayon-h">
               </span>
               [Order_No]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3e6662721728-3">
               <span class="crayon-h">
               </span>
               [Table_ID]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3e6662721728-4">
               <span class="crayon-h">
               </span>
               [Description]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](200)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3e6662721728-5">
               <span class="crayon-h">
               </span>
               [IN_DATE]
               <span class="crayon-h">
               </span>
               [datetime]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3e6662721728-6">
               <span class="crayon-h">
               </span>
               [IN_USR_ID]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3e6662721728-7">
               <span class="crayon-h">
               </span>
               [UP_DATE]
               <span class="crayon-h">
               </span>
               [datetime]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3e6662721728-8">
               <span class="crayon-h">
               </span>
               [UP_USR_ID]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3e6662721728-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                CONSTRAINT
               </span>
               <span class="crayon-h">
               </span>
               [PK_OrderMasters]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                PRIMARY
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                KEY
               </span>
               <span class="crayon-h">
               </span>
               CLUSTERED
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3e6662721728-10">
               (
              </div>
              <div class="crayon-line" id="crayon-576865bbed3e6662721728-11">
               <span class="crayon-h">
               </span>
               [Order_No]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ASC
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3e6662721728-12">
               )
               <span class="crayon-st">
                WITH
               </span>
               <span class="crayon-h">
               </span>
               (PAD_INDEX
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               STATISTICS_NORECOMPUTE
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               IGNORE_DUP_KEY
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               ALLOW_ROW_LOCKS
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               ,
               <span class="crayon-h">
               </span>
               ALLOW_PAGE_LOCKS
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-r">
                PRIMARY
               </span>
               ]
              </div>
              <div class="crayon-line" id="crayon-576865bbed3e6662721728-13">
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-r">
                PRIMARY
               </span>
               ]
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0045 seconds] -->
       <p>
        <strong>
         向Order Master表插入数据：
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed3ef134254838" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          INSERT INTO [OrderMasters]
           ([Order_No],[Table_ID] ,[Description],[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('Ord_001','T1','',GETDATE(),'SHANU' ,GETDATE(),'SHANU')

INSERT INTO [OrderMasters]
           ([Order_No],[Table_ID] ,[Description],[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('Ord_002','T2','',GETDATE(),'Mak' ,GETDATE(),'MAK')

INSERT INTO [OrderMasters]
           ([Order_No],[Table_ID] ,[Description],[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('Ord_003','T3','',GETDATE(),'RAJ' ,GETDATE(),'RAJ')
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed3ef134254838-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3ef134254838-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3ef134254838-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3ef134254838-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3ef134254838-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3ef134254838-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3ef134254838-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3ef134254838-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3ef134254838-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3ef134254838-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3ef134254838-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3ef134254838-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3ef134254838-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3ef134254838-14">
               14
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed3ef134254838-1">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderMasters]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3ef134254838-2">
               <span class="crayon-h">
               </span>
               ([Order_No],[Table_ID]
               <span class="crayon-h">
               </span>
               ,[Description],[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3ef134254838-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3ef134254838-4">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Ord_001'
               </span>
               ,
               <span class="crayon-s">
                'T1'
               </span>
               ,
               <span class="crayon-s">
                ''
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line" id="crayon-576865bbed3ef134254838-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3ef134254838-6">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderMasters]
              </div>
              <div class="crayon-line" id="crayon-576865bbed3ef134254838-7">
               <span class="crayon-h">
               </span>
               ([Order_No],[Table_ID]
               <span class="crayon-h">
               </span>
               ,[Description],[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3ef134254838-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3ef134254838-9">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Ord_002'
               </span>
               ,
               <span class="crayon-s">
                'T2'
               </span>
               ,
               <span class="crayon-s">
                ''
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'Mak'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'MAK'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3ef134254838-10">
              </div>
              <div class="crayon-line" id="crayon-576865bbed3ef134254838-11">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderMasters]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3ef134254838-12">
               <span class="crayon-h">
               </span>
               ([Order_No],[Table_ID]
               <span class="crayon-h">
               </span>
               ,[Description],[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3ef134254838-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3ef134254838-14">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Ord_003'
               </span>
               ,
               <span class="crayon-s">
                'T3'
               </span>
               ,
               <span class="crayon-s">
                ''
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'RAJ'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'RAJ'
               </span>
               )
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0034 seconds] -->
       <p>
        <strong>
         创建Order Detail表：
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed3f8903320310" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE TABLE [dbo].[OrderDetails](
	[Order_Detail_No] [varchar](20) NOT NULL,
	[Order_No] [varchar](20) CONSTRAINT  fk_OrderMasters FOREIGN KEY REFERENCES OrderMasters(Order_No),
	[Item_Code] [varchar](20) CONSTRAINT  fk_ItemMasters FOREIGN KEY REFERENCES ItemMasters(Item_Code),
	[Notes] [varchar](200) NOT NULL,
	[QTY]  INT NOT NULL,
	[IN_DATE] [datetime] NOT NULL,
	[IN_USR_ID] [varchar](20) NOT NULL,
	[UP_DATE] [datetime] NOT NULL,
	[UP_USR_ID] [varchar](20) NOT NULL,
 CONSTRAINT [PK_OrderDetails] PRIMARY KEY CLUSTERED 
(
	[Order_Detail_No] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

--Now let&amp;amp;rsquo;s insert the 3 items for the above Order No 'Ord_001'.
INSERT INTO [OrderDetails]
           ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
           ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('OR_Dt_001','Ord_001','Item001','Need very Cold',3
           ,GETDATE(),'SHANU' ,GETDATE(),'SHANU')

INSERT INTO [OrderDetails]
           ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
           ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('OR_Dt_002','Ord_001','Item004','very Hot ',2
           ,GETDATE(),'SHANU' ,GETDATE(),'SHANU')

INSERT INTO [OrderDetails]
           ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
           ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('OR_Dt_003','Ord_001','Item003','Very Spicy',4
           ,GETDATE(),'SHANU' ,GETDATE(),'SHANU')
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-32">
               32
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-33">
               33
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-34">
               34
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-35">
               35
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed3f8903320310-36">
               36
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed3f8903320310-37">
               37
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-1">
               <span class="crayon-st">
                CREATE
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                TABLE
               </span>
               <span class="crayon-h">
               </span>
               [dbo].[OrderDetails](
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-2">
               <span class="crayon-h">
               </span>
               [Order_Detail_No]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-3">
               <span class="crayon-h">
               </span>
               [Order_No]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                CONSTRAINT
               </span>
               <span class="crayon-h">
               </span>
               fk_OrderMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                FOREIGN
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                KEY
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                REFERENCES
               </span>
               <span class="crayon-h">
               </span>
               OrderMasters(Order_No),
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-4">
               <span class="crayon-h">
               </span>
               [Item_Code]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                CONSTRAINT
               </span>
               <span class="crayon-h">
               </span>
               fk_ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                FOREIGN
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                KEY
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                REFERENCES
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters(Item_Code),
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-5">
               <span class="crayon-h">
               </span>
               [Notes]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](200)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-6">
               <span class="crayon-h">
               </span>
               [QTY]
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                INT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-7">
               <span class="crayon-h">
               </span>
               [IN_DATE]
               <span class="crayon-h">
               </span>
               [datetime]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-8">
               <span class="crayon-h">
               </span>
               [IN_USR_ID]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-9">
               <span class="crayon-h">
               </span>
               [UP_DATE]
               <span class="crayon-h">
               </span>
               [datetime]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-10">
               <span class="crayon-h">
               </span>
               [UP_USR_ID]
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-t">
                varchar
               </span>
               ](20)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                NOT NULL
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                CONSTRAINT
               </span>
               <span class="crayon-h">
               </span>
               [PK_OrderDetails]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                PRIMARY
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                KEY
               </span>
               <span class="crayon-h">
               </span>
               CLUSTERED
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-12">
               (
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-13">
               <span class="crayon-h">
               </span>
               [Order_Detail_No]
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ASC
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-14">
               )
               <span class="crayon-st">
                WITH
               </span>
               <span class="crayon-h">
               </span>
               (PAD_INDEX
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               STATISTICS_NORECOMPUTE
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               IGNORE_DUP_KEY
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                OFF
               </span>
               ,
               <span class="crayon-h">
               </span>
               ALLOW_ROW_LOCKS
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               ,
               <span class="crayon-h">
               </span>
               ALLOW_PAGE_LOCKS
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-r">
                PRIMARY
               </span>
               ]
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-15">
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               [
               <span class="crayon-r">
                PRIMARY
               </span>
               ]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-16">
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-17">
               <span class="crayon-c">
                --Now let&amp;amp;rsquo;s insert the 3 items for the above Order No 'Ord_001'.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-18">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderDetails]
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-19">
               <span class="crayon-h">
               </span>
               ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-20">
               <span class="crayon-h">
               </span>
               ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-21">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-22">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'OR_Dt_001'
               </span>
               ,
               <span class="crayon-s">
                'Ord_001'
               </span>
               ,
               <span class="crayon-s">
                'Item001'
               </span>
               ,
               <span class="crayon-s">
                'Need very Cold'
               </span>
               ,3
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-23">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-24">
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-25">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderDetails]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-26">
               <span class="crayon-h">
               </span>
               ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-27">
               <span class="crayon-h">
               </span>
               ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-28">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-29">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'OR_Dt_002'
               </span>
               ,
               <span class="crayon-s">
                'Ord_001'
               </span>
               ,
               <span class="crayon-s">
                'Item004'
               </span>
               ,
               <span class="crayon-s">
                'very Hot '
               </span>
               ,2
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-30">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-31">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-32">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderDetails]
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-33">
               <span class="crayon-h">
               </span>
               ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-34">
               <span class="crayon-h">
               </span>
               ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-35">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed3f8903320310-36">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'OR_Dt_003'
               </span>
               ,
               <span class="crayon-s">
                'Ord_001'
               </span>
               ,
               <span class="crayon-s">
                'Item003'
               </span>
               ,
               <span class="crayon-s">
                'Very Spicy'
               </span>
               ,4
              </div>
              <div class="crayon-line" id="crayon-576865bbed3f8903320310-37">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0103 seconds] -->
       <p>
        <strong>
         向Order Detail表插入数据：
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed405415057361" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          INSERT INTO [OrderDetails]
           ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
           ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('OR_Dt_004','Ord_002','Item002','Need very Hot',2
           ,GETDATE(),'SHANU' ,GETDATE(),'SHANU')

INSERT INTO [OrderDetails]
           ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
           ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('OR_Dt_005','Ord_002','Item003','very Hot ',2
           ,GETDATE(),'SHANU' ,GETDATE(),'SHANU')

INSERT INTO [OrderDetails]
           ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
           ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
     VALUES
           ('OR_Dt_006','Ord_003','Item003','Very Spicy',4
           ,GETDATE(),'SHANU' ,GETDATE(),'SHANU')
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed405415057361-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed405415057361-20">
               20
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed405415057361-1">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderDetails]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-2">
               <span class="crayon-h">
               </span>
               ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-3">
               <span class="crayon-h">
               </span>
               ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-5">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'OR_Dt_004'
               </span>
               ,
               <span class="crayon-s">
                'Ord_002'
               </span>
               ,
               <span class="crayon-s">
                'Item002'
               </span>
               ,
               <span class="crayon-s">
                'Need very Hot'
               </span>
               ,2
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-6">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-8">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderDetails]
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-9">
               <span class="crayon-h">
               </span>
               ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-10">
               <span class="crayon-h">
               </span>
               ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-12">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'OR_Dt_005'
               </span>
               ,
               <span class="crayon-s">
                'Ord_002'
               </span>
               ,
               <span class="crayon-s">
                'Item003'
               </span>
               ,
               <span class="crayon-s">
                'very Hot '
               </span>
               ,2
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-13">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-14">
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-15">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               [OrderDetails]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-16">
               <span class="crayon-h">
               </span>
               ([Order_Detail_No],[Order_No],[Item_Code],[Notes],[QTY]
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-17">
               <span class="crayon-h">
               </span>
               ,[IN_DATE],[IN_USR_ID],[UP_DATE],[UP_USR_ID])
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                VALUES
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed405415057361-19">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'OR_Dt_006'
               </span>
               ,
               <span class="crayon-s">
                'Ord_003'
               </span>
               ,
               <span class="crayon-s">
                'Item003'
               </span>
               ,
               <span class="crayon-s">
                'Very Spicy'
               </span>
               ,4
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed405415057361-20">
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               <span class="crayon-h">
               </span>
               ,GETDATE(),
               <span class="crayon-s">
                'SHANU'
               </span>
               )
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0041 seconds] -->
       <p>
       </p>
       <h2>
        2、简单的Select查询语句
       </h2>
       <p>
        Select查询语句是SQL中最基本也是最重要的DML语句之一。那么什么是DML？DML全称Data Manipulation Language（数据操纵语言命令），它可以使用户能够查询数据库以及操作已有数据库中的数据。
       </p>
       <p>
        下面我们在SQL Server中用select语句来查询我的姓名(Name)：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed40f242996630" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          SELECT 'My Name Is SYED SHANU'
-- With Column Name using 'AS'
SELECT 'My Name Is SYED SHANU' as 'MY NAME'
-- With more then the one Column 
SELECT 'My Name' as 'Column1', 'Is' as 'Column2', 'SYED SHANU' as 'Column3'
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed40f242996630-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed40f242996630-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed40f242996630-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed40f242996630-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed40f242996630-5">
               5
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed40f242996630-1">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'My Name Is SYED SHANU'
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed40f242996630-2">
               <span class="crayon-c">
                -- With Column Name using 'AS'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed40f242996630-3">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'My Name Is SYED SHANU'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'MY NAME'
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed40f242996630-4">
               <span class="crayon-c">
                -- With more then the one Column
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed40f242996630-5">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'My Name'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'Column1'
               </span>
               ,
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'Is'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'Column2'
               </span>
               ,
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'SYED SHANU'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'Column3'
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0014 seconds] -->
       <p>
        <strong>
         在数据表中使用select查询：
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed415455175353" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- To Display all the columns from the table we use * operator in select Statement.
Select * from ItemMasters
-- If we need to select only few fields from a table we can use the Column Name in Select Statement.
Select    Item_Code
		,Item_name as Item
		,Price
		,Description
		,In_DATE
		FROM
		ItemMasters
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed415455175353-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed415455175353-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed415455175353-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed415455175353-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed415455175353-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed415455175353-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed415455175353-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed415455175353-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed415455175353-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed415455175353-10">
               10
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed415455175353-1">
               <span class="crayon-c">
                -- To Display all the columns from the table we use * operator in select Statement.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed415455175353-2">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed415455175353-3">
               <span class="crayon-c">
                -- If we need to select only few fields from a table we can use the Column Name in Select Statement.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed415455175353-4">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Item_Code
              </div>
              <div class="crayon-line" id="crayon-576865bbed415455175353-5">
               <span class="crayon-h">
               </span>
               ,Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               Item
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed415455175353-6">
               <span class="crayon-h">
               </span>
               ,Price
              </div>
              <div class="crayon-line" id="crayon-576865bbed415455175353-7">
               <span class="crayon-h">
               </span>
               ,Description
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed415455175353-8">
               <span class="crayon-h">
               </span>
               ,In_DATE
              </div>
              <div class="crayon-line" id="crayon-576865bbed415455175353-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed415455175353-10">
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0015 seconds] -->
       <p>
       </p>
       <h2>
        3、合计和标量函数
       </h2>
       <p>
        合计函数和标量函数都是SQL Server的内置函数，我们可以在select查询语句中使用它们，比如Count(), Max(), Sum(), Upper(), lower(), Round()等等。下面我们用SQL代码来解释这些函数的用法：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed41c874744303" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          select * from ItemMasters
-- Aggregate
-- COUNT() -&amp;gt; returns the Total no of records from table , AVG() returns the Average Value from Colum,MAX() Returns MaX Value from Column
-- ,MIN() returns Min Value from Column,SUM()  sum of total from Column
Select Count(*)  TotalRows,AVG(Price) AVGPrice
		,MAX(Price) MAXPrice,MIN(Price) MinPrice,Sum(price) PriceTotal 
		FROM ItemMasters

-- Scalar 
-- UCASE() -&amp;gt; Convert to  Upper Case  ,LCASE() -&amp;gt; Convert to Lower Case,
-- SUBSTRING() -&amp;gt;Display selected char from column -&amp;gt;SUBSTRING(ColumnName,StartIndex,LenthofChartoDisplay)
--,LEN() -&amp;gt; lenth of column date,
-- ROUND()  -&amp;gt; Which will round the value
SELECT  UPPER(Item_NAME) Uppers,LOWER(Item_NAME) Lowers,
		SUBSTRING(Item_NAME,2,3) MidValue,LEN(Item_NAME) Lenths 
	   ,SUBSTRING(Item_NAME,2,LEN(Item_NAME)) MidValuewithLenFunction, 
	    ROUND(Price,0) as Rounded
		FROM ItemMasters
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed41c874744303-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed41c874744303-18">
               18
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed41c874744303-1">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-2">
               <span class="crayon-c">
                -- Aggregate
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-3">
               <span class="crayon-c">
                -- COUNT() -&amp;gt; returns the Total no of records from table , AVG() returns the Average Value from Colum,MAX() Returns MaX Value from Column
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-4">
               <span class="crayon-c">
                -- ,MIN() returns Min Value from Column,SUM()  sum of total from Column
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-5">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                Count
               </span>
               (*)
               <span class="crayon-h">
               </span>
               TotalRows,
               <span class="crayon-e ">
                AVG
               </span>
               (Price)
               <span class="crayon-h">
               </span>
               AVGPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-6">
               <span class="crayon-h">
               </span>
               ,
               <span class="crayon-e ">
                MAX
               </span>
               (Price)
               <span class="crayon-h">
               </span>
               MAXPrice,
               <span class="crayon-e ">
                MIN
               </span>
               (Price)
               <span class="crayon-h">
               </span>
               MinPrice,
               <span class="crayon-e ">
                Sum
               </span>
               (price)
               <span class="crayon-h">
               </span>
               PriceTotal
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-8">
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-9">
               <span class="crayon-c">
                -- Scalar
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-10">
               <span class="crayon-c">
                -- UCASE() -&amp;gt; Convert to  Upper Case  ,LCASE() -&amp;gt; Convert to Lower Case,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-11">
               <span class="crayon-c">
                -- SUBSTRING() -&amp;gt;Display selected char from column -&amp;gt;SUBSTRING(ColumnName,StartIndex,LenthofChartoDisplay)
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-12">
               <span class="crayon-c">
                --,LEN() -&amp;gt; lenth of column date,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-13">
               <span class="crayon-c">
                -- ROUND()  -&amp;gt; Which will round the value
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-14">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                UPPER
               </span>
               (Item_NAME)
               <span class="crayon-h">
               </span>
               Uppers,
               <span class="crayon-e ">
                LOWER
               </span>
               (Item_NAME)
               <span class="crayon-h">
               </span>
               Lowers,
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                SUBSTRING
               </span>
               (Item_NAME,2,3)
               <span class="crayon-h">
               </span>
               MidValue,LEN(Item_NAME)
               <span class="crayon-h">
               </span>
               Lenths
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-16">
               <span class="crayon-h">
               </span>
               ,
               <span class="crayon-e ">
                SUBSTRING
               </span>
               (Item_NAME,2,LEN(Item_NAME))
               <span class="crayon-h">
               </span>
               MidValuewithLenFunction,
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed41c874744303-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                ROUND
               </span>
               (Price,0)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               Rounded
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed41c874744303-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0041 seconds] -->
       <p>
       </p>
       <h2>
        4、日期函数
       </h2>
       <p>
        在我们的项目数据表中基本都会使用到日期列，因此日期函数在项目中扮演着非常重要的角色。有时候我们对日期函数要非常的小心，它随时可以给你带来巨大的麻烦。在项目中，我们要选择合适的日期函数和日期格式，下面是一些SQL日期函数的例子：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed423207964964" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- GETDATE() -&amp;gt; to Display the Current Date and Time
-- Format() -&amp;gt; used to display our date in our requested format
Select GETDATE() CurrentDateTime, FORMAT(GETDATE(),'yyyy-MM-dd') AS DateFormats,
	   FORMAT(GETDATE(),'HH-mm-ss')TimeFormats,
	   CONVERT(VARCHAR(10),GETDATE(),10) Converts1,
	   CONVERT(VARCHAR(24),GETDATE(),113),
	   CONVERT(NVARCHAR, getdate(), 106) Converts2 ,-- here we used Convert Function 
	  REPLACE(convert(NVARCHAR, getdate(), 106), ' ', '/') Formats-- Here we used replace and --convert functions.
	  --first we convert the date to nvarchar and then we replace the '' with '/' 

select * from Itemmasters

Select  ITEM_NAME,IN_DATE CurrentDateTime, FORMAT(IN_DATE,'yyyy-MM-dd') AS DateFormats,
		FORMAT(IN_DATE,'HH-mm-ss')TimeFormats,
		CONVERT(VARCHAR(10),IN_DATE,10) Converts1,
		CONVERT(VARCHAR(24),IN_DATE,113),
		convert(NVARCHAR, IN_DATE, 106) Converts2 ,-- here we used Convert Function 
		REPLACE(convert(NVARCHAR,IN_DATE, 106), ' ', '/') Formats
		FROM Itemmasters
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed423207964964-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed423207964964-19">
               19
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed423207964964-1">
               <span class="crayon-c">
                -- GETDATE() -&amp;gt; to Display the Current Date and Time
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-2">
               <span class="crayon-c">
                -- Format() -&amp;gt; used to display our date in our requested format
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-3">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               GETDATE()
               <span class="crayon-h">
               </span>
               CurrentDateTime,
               <span class="crayon-h">
               </span>
               FORMAT(GETDATE(),
               <span class="crayon-s">
                'yyyy-MM-dd'
               </span>
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               DateFormats,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-4">
               <span class="crayon-h">
               </span>
               FORMAT(GETDATE(),
               <span class="crayon-s">
                'HH-mm-ss'
               </span>
               )TimeFormats,
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                CONVERT
               </span>
               (
               <span class="crayon-t">
                VARCHAR
               </span>
               (10),GETDATE(),10)
               <span class="crayon-h">
               </span>
               Converts1,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                CONVERT
               </span>
               (
               <span class="crayon-t">
                VARCHAR
               </span>
               (24),GETDATE(),113),
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                CONVERT
               </span>
               (NVARCHAR,
               <span class="crayon-h">
               </span>
               getdate(),
               <span class="crayon-h">
               </span>
               106)
               <span class="crayon-h">
               </span>
               Converts2
               <span class="crayon-h">
               </span>
               ,
               <span class="crayon-c">
                -- here we used Convert Function
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                REPLACE
               </span>
               (
               <span class="crayon-e ">
                convert
               </span>
               (NVARCHAR,
               <span class="crayon-h">
               </span>
               getdate(),
               <span class="crayon-h">
               </span>
               106),
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ' '
               </span>
               ,
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '/'
               </span>
               )
               <span class="crayon-h">
               </span>
               Formats
               <span class="crayon-c">
                -- Here we used replace and --convert functions.
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                --first we convert the date to nvarchar and then we replace the '' with '/'
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-10">
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-11">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               Itemmasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-12">
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-13">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               ITEM_NAME,IN_DATE
               <span class="crayon-h">
               </span>
               CurrentDateTime,
               <span class="crayon-h">
               </span>
               FORMAT(IN_DATE,
               <span class="crayon-s">
                'yyyy-MM-dd'
               </span>
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               DateFormats,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-14">
               <span class="crayon-h">
               </span>
               FORMAT(IN_DATE,
               <span class="crayon-s">
                'HH-mm-ss'
               </span>
               )TimeFormats,
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                CONVERT
               </span>
               (
               <span class="crayon-t">
                VARCHAR
               </span>
               (10),IN_DATE,10)
               <span class="crayon-h">
               </span>
               Converts1,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                CONVERT
               </span>
               (
               <span class="crayon-t">
                VARCHAR
               </span>
               (24),IN_DATE,113),
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                convert
               </span>
               (NVARCHAR,
               <span class="crayon-h">
               </span>
               IN_DATE,
               <span class="crayon-h">
               </span>
               106)
               <span class="crayon-h">
               </span>
               Converts2
               <span class="crayon-h">
               </span>
               ,
               <span class="crayon-c">
                -- here we used Convert Function
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed423207964964-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                REPLACE
               </span>
               (
               <span class="crayon-e ">
                convert
               </span>
               (NVARCHAR,IN_DATE,
               <span class="crayon-h">
               </span>
               106),
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ' '
               </span>
               ,
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '/'
               </span>
               )
               <span class="crayon-h">
               </span>
               Formats
              </div>
              <div class="crayon-line" id="crayon-576865bbed423207964964-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               Itemmasters
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0057 seconds] -->
       <p>
        <strong>
         DatePart
        </strong>
        –&gt;  该函数可以获取年、月、日的信息。
       </p>
       <p>
        <strong>
         DateADD
        </strong>
        –&gt;  该函数可以对当前的日期进行加减。
       </p>
       <p>
        <strong>
         DateDiff
        </strong>
        –&gt;  该函数可以比较2个日期。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed42a937451308" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --Datepart DATEPART(dateparttype,yourDate)
SELECT DATEPART(yyyy,getdate()) AS YEARs ,
DATEPART(mm,getdate()) AS MONTHS,
DATEPART(dd,getdate()) AS Days,
DATEPART(week,getdate()) AS weeks,
DATEPART(hour,getdate()) AS hours

--Days Add to add or subdtract date from a selected date.
SELECT GetDate()CurrentDate,DATEADD(day,12,getdate()) AS AddDays ,
 DATEADD(day,-4,getdate()) AS FourDaysBeforeDate 

 -- DATEDIFF() -&amp;gt; to display the Days between 2 dates
 select DATEDIFF(year,'2003-08-05',getdate())  yearDifferance , 
  DATEDIFF(day,DATEADD(day,-24,getdate()),getdate()) daysDifferent,
 DATEDIFF(month,getdate(),DATEADD(Month,6,getdate())) MonthDifferance
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed42a937451308-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed42a937451308-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed42a937451308-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed42a937451308-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed42a937451308-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed42a937451308-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed42a937451308-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed42a937451308-15">
               15
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed42a937451308-1">
               <span class="crayon-c">
                --Datepart DATEPART(dateparttype,yourDate)
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed42a937451308-2">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               DATEPART(yyyy,getdate())
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               YEARs
               <span class="crayon-h">
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed42a937451308-3">
               DATEPART(mm,getdate())
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               MONTHS,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed42a937451308-4">
               DATEPART(dd,getdate())
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               Days,
              </div>
              <div class="crayon-line" id="crayon-576865bbed42a937451308-5">
               DATEPART(week,getdate())
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               weeks,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed42a937451308-6">
               DATEPART(
               <span class="crayon-r">
                hour
               </span>
               ,getdate())
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               hours
              </div>
              <div class="crayon-line" id="crayon-576865bbed42a937451308-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed42a937451308-8">
               <span class="crayon-c">
                --Days Add to add or subdtract date from a selected date.
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed42a937451308-9">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               GetDate()CurrentDate,DATEADD(
               <span class="crayon-r">
                day
               </span>
               ,12,getdate())
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               AddDays
               <span class="crayon-h">
               </span>
               ,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed42a937451308-10">
               <span class="crayon-h">
               </span>
               DATEADD(
               <span class="crayon-r">
                day
               </span>
               ,-4,getdate())
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               FourDaysBeforeDate
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed42a937451308-11">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed42a937451308-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                -- DATEDIFF() -&amp;gt; to display the Days between 2 dates
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed42a937451308-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               DATEDIFF(
               <span class="crayon-r">
                year
               </span>
               ,
               <span class="crayon-s">
                '2003-08-05'
               </span>
               ,getdate())
               <span class="crayon-h">
               </span>
               yearDifferance
               <span class="crayon-h">
               </span>
               ,
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed42a937451308-14">
               <span class="crayon-h">
               </span>
               DATEDIFF(
               <span class="crayon-r">
                day
               </span>
               ,DATEADD(
               <span class="crayon-r">
                day
               </span>
               ,-24,getdate()),getdate())
               <span class="crayon-h">
               </span>
               daysDifferent,
              </div>
              <div class="crayon-line" id="crayon-576865bbed42a937451308-15">
               <span class="crayon-h">
               </span>
               DATEDIFF(
               <span class="crayon-r">
                month
               </span>
               ,getdate(),DATEADD(
               <span class="crayon-r">
                Month
               </span>
               ,6,getdate()))
               <span class="crayon-h">
               </span>
               MonthDifferance
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0044 seconds] -->
       <p>
       </p>
       <h2>
        5、其他Select函数
       </h2>
       <p>
        <strong>
         Top
        </strong>
        —— 结合select语句，Top函数可以查询头几条和末几条的数据记录。
       </p>
       <p>
        <strong>
         Order By
        </strong>
        —— 结合select语句，Order By可以让查询结果按某个字段正序和逆序输出数据记录。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed431108956502" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --Top to Select Top first and last records using Select Statement.
Select * FROM ItemMasters
--&amp;gt; First Display top 2 Records
Select TOP 2 Item_Code
			 ,Item_name as Item
			 ,Price
			 ,Description
			 ,In_DATE
FROM ItemMasters
--&amp;gt; to Display the Last to Records we need to use the Order By Clause
-- order By to display Records in assending or desending order by the columns
Select TOP 2  Item_Code
			 ,Item_name as Item
			 ,Price
			 ,Description
			 ,In_DATE
FROM ItemMasters
ORDER BY Item_Code DESC
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed431108956502-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed431108956502-18">
               18
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed431108956502-1">
               <span class="crayon-c">
                --Top to Select Top first and last records using Select Statement.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-2">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-3">
               <span class="crayon-c">
                --&amp;gt; First Display top 2 Records
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-4">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               TOP
               <span class="crayon-h">
               </span>
               2
               <span class="crayon-h">
               </span>
               Item_Code
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-5">
               <span class="crayon-h">
               </span>
               ,Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               Item
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-6">
               <span class="crayon-h">
               </span>
               ,Price
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-7">
               <span class="crayon-h">
               </span>
               ,Description
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-8">
               <span class="crayon-h">
               </span>
               ,In_DATE
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-9">
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-10">
               <span class="crayon-c">
                --&amp;gt; to Display the Last to Records we need to use the Order By Clause
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-11">
               <span class="crayon-c">
                -- order By to display Records in assending or desending order by the columns
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-12">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               TOP
               <span class="crayon-h">
               </span>
               2
               <span class="crayon-h">
               </span>
               Item_Code
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-13">
               <span class="crayon-h">
               </span>
               ,Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               Item
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-14">
               <span class="crayon-h">
               </span>
               ,Price
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-15">
               <span class="crayon-h">
               </span>
               ,Description
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-16">
               <span class="crayon-h">
               </span>
               ,In_DATE
              </div>
              <div class="crayon-line" id="crayon-576865bbed431108956502-17">
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed431108956502-18">
               <span class="crayon-r">
                ORDER
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                BY
               </span>
               <span class="crayon-h">
               </span>
               Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                DESC
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0029 seconds] -->
       <p>
        <strong>
         Distinct
        </strong>
        ——
       </p>
       <p>
        distinct关键字可以过滤重复的数据记录。
       </p>
       <p>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed437155819367" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Select * FROM ItemMasters
--Distinct -&amp;gt; To avoid the Duplicate records we use the distinct in select statement
-- for example in this table we can see here we have the duplicate record 'Chiken Burger'
-- but with different Item_Code when i use the below select statement see what happen

Select   Item_name as Item
		,Price
		,Description	
		,IN_USR_ID	
		FROM ItemMasters
-- here we can see the Row No 3 and 5 have the duplicate record to avoid this we use the distinct Keyword in select statement.

select Distinct Item_name as Item
				,Price
				,Description	
				,IN_USR_ID	
				 FROM ItemMasters
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed437155819367-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed437155819367-17">
               17
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed437155819367-1">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-2">
               <span class="crayon-c">
                --Distinct -&amp;gt; To avoid the Duplicate records we use the distinct in select statement
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-3">
               <span class="crayon-c">
                -- for example in this table we can see here we have the duplicate record 'Chiken Burger'
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-4">
               <span class="crayon-c">
                -- but with different Item_Code when i use the below select statement see what happen
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-6">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               Item
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-7">
               <span class="crayon-h">
               </span>
               ,Price
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-8">
               <span class="crayon-h">
               </span>
               ,Description
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-9">
               <span class="crayon-h">
               </span>
               ,IN_USR_ID
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-11">
               <span class="crayon-c">
                -- here we can see the Row No 3 and 5 have the duplicate record to avoid this we use the distinct Keyword in select statement.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-12">
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-13">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Distinct
               </span>
               <span class="crayon-h">
               </span>
               Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               Item
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-14">
               <span class="crayon-h">
               </span>
               ,Price
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-15">
               <span class="crayon-h">
               </span>
               ,Description
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed437155819367-16">
               <span class="crayon-h">
               </span>
               ,IN_USR_ID
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed437155819367-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0024 seconds] -->
       <p>
       </p>
       <h2>
        6、Where子句
       </h2>
       <p>
        Where子句在SQL Select查询语句中非常重要，为什么要使用where子句？什么时候使用where子句？where子句是利用一些条件来过滤数据结果集。
       </p>
       <p>
        下面我们从10000条数据记录中查询Order_No为某个值或者某个区间的数据记录，另外还有其他的条件。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed43e980234214" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Select * from ItemMasters
Select * from OrderDetails
--Where -&amp;gt; To display the data with certain conditions
-- Now below example which will display all the records which has Item_Name='Coke'
select * FROM ItemMasters WHERE ITEM_NAME='COKE'
-- If we want display all the records Iten_Name which Starts with 'C' then we use Like in where clause.
SELECT * FROM ItemMasters WHERE ITEM_NAME Like 'C%'

--&amp;gt; here we display the ItemMasters where the price will be greater then or equal to 40.
--&amp;gt; to use more then one condition we can Use And or Or operator.
--If we want to check the data between to date range then we can use Between Operator in Where Clause.
select Item_name as Item
		,Price
		,Description	
		,IN_USR_ID	
		 FROM ItemMasters
		 WHERE
			ITEM_NAME Like 'C%' 
			AND 
			price &amp;gt;=40
--&amp;gt; here we display the OrderDetails where the Qty will be greater 3

Select * FROM OrderDetails WHERE qty&amp;gt;3
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed43e980234214-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed43e980234214-23">
               23
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed43e980234214-1">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-2">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-3">
               <span class="crayon-c">
                --Where -&amp;gt; To display the data with certain conditions
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-4">
               <span class="crayon-c">
                -- Now below example which will display all the records which has Item_Name='Coke'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-5">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               ITEM_NAME=
               <span class="crayon-s">
                'COKE'
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-6">
               <span class="crayon-c">
                -- If we want display all the records Iten_Name which Starts with 'C' then we use Like in where clause.
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-7">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               ITEM_NAME
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Like
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'C%'
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-8">
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-9">
               <span class="crayon-c">
                --&amp;gt; here we display the ItemMasters where the price will be greater then or equal to 40.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-10">
               <span class="crayon-c">
                --&amp;gt; to use more then one condition we can Use And or Or operator.
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-11">
               <span class="crayon-c">
                --If we want to check the data between to date range then we can use Between Operator in Where Clause.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-12">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               Item
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-13">
               <span class="crayon-h">
               </span>
               ,Price
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-14">
               <span class="crayon-h">
               </span>
               ,Description
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-15">
               <span class="crayon-h">
               </span>
               ,IN_USR_ID
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-18">
               <span class="crayon-h">
               </span>
               ITEM_NAME
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Like
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'C%'
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AND
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-20">
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;gt;
               </span>
               =40
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-21">
               <span class="crayon-c">
                --&amp;gt; here we display the OrderDetails where the Qty will be greater 3
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed43e980234214-22">
              </div>
              <div class="crayon-line" id="crayon-576865bbed43e980234214-23">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               qty
               <span class="crayon-o">
                &amp;
               </span>
               gt;3
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0054 seconds] -->
       <p>
        <strong>
         Where – In 子句
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed444301020530" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- In clause -&amp;gt; used to display the data which is in the condition
select *
		FROM ItemMasters
		WHERE
		Item_name IN ('Coffee','Chiken Burger')

-- In clause with Order By - Here we display the in descending order.
select *
		FROM ItemMasters
		WHERE
		Item_name IN ('Coffee','Chiken Burger')
		ORDER BY Item_Code Desc
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed444301020530-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed444301020530-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed444301020530-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed444301020530-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed444301020530-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed444301020530-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed444301020530-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed444301020530-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed444301020530-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed444301020530-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed444301020530-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed444301020530-12">
               12
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed444301020530-1">
               <span class="crayon-c">
                -- In clause -&amp;gt; used to display the data which is in the condition
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed444301020530-2">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
              </div>
              <div class="crayon-line" id="crayon-576865bbed444301020530-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed444301020530-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed444301020530-5">
               <span class="crayon-h">
               </span>
               Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                IN
               </span>
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Coffee'
               </span>
               ,
               <span class="crayon-s">
                'Chiken Burger'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed444301020530-6">
              </div>
              <div class="crayon-line" id="crayon-576865bbed444301020530-7">
               <span class="crayon-c">
                -- In clause with Order By - Here we display the in descending order.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed444301020530-8">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
              </div>
              <div class="crayon-line" id="crayon-576865bbed444301020530-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed444301020530-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed444301020530-11">
               <span class="crayon-h">
               </span>
               Item_name
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                IN
               </span>
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-s">
                'Coffee'
               </span>
               ,
               <span class="crayon-s">
                'Chiken Burger'
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed444301020530-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ORDER
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                BY
               </span>
               <span class="crayon-h">
               </span>
               Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Desc
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0023 seconds] -->
       <p>
        <strong>
         Where – Between子句
        </strong>
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed44a780199945" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- between  -&amp;gt; Now if we want to display the data between to date range then we use betweeen keyword
select * FROM ItemMasters

select * FROM ItemMasters
		 WHERE
		 In_Date BETWEEN '2014-09-22 15:59:02.853' AND '2014-09-22 15:59:02.853'

select * FROM ItemMasters
		 WHERE
		 ITEM_NAME Like 'C%' 
		 AND
		 In_Date BETWEEN '2014-09-22 15:59:02.853' AND '2014-09-22 15:59:02.853'
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed44a780199945-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed44a780199945-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed44a780199945-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed44a780199945-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed44a780199945-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed44a780199945-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed44a780199945-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed44a780199945-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed44a780199945-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed44a780199945-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed44a780199945-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed44a780199945-12">
               12
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed44a780199945-1">
               <span class="crayon-c">
                -- between  -&amp;gt; Now if we want to display the data between to date range then we use betweeen keyword
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed44a780199945-2">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed44a780199945-3">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed44a780199945-4">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed44a780199945-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed44a780199945-6">
               <span class="crayon-h">
               </span>
               In_Date
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                BETWEEN
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '2014-09-22 15:59:02.853'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AND
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '2014-09-22 15:59:02.853'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed44a780199945-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed44a780199945-8">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed44a780199945-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed44a780199945-10">
               <span class="crayon-h">
               </span>
               ITEM_NAME
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Like
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'C%'
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed44a780199945-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AND
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed44a780199945-12">
               <span class="crayon-h">
               </span>
               In_Date
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                BETWEEN
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '2014-09-22 15:59:02.853'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AND
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '2014-09-22 15:59:02.853'
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0025 seconds] -->
       <p>
        查询某个条件区间的数据，我们常常使用between子句。
       </p>
       <h2>
        7、Group By 子句
       </h2>
       <p>
        Group By子句可以对查询的结果集按指定字段分组：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed450301286648" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --Group By -&amp;gt; To display the data with group result.Here we can see we display all the AQggregate result by Item Name
Select ITEM_NAME,Count(*)  TotalRows,AVG(Price) AVGPrice
		,MAX(Price) MAXPrice,MIN(Price) MinPrice,Sum(price) PriceTotal 
		FROM
		ItemMasters
		GROUP BY ITEM_NAME

-- Here this group by will combine all the same Order_No result and make the total or each order_NO
Select Order_NO,Sum(QTy) as TotalQTY 
	FROM OrderDetails
	where qty&amp;gt;=2
	GROUP BY Order_NO

-- Here the Total will be created by order_No and Item_Code
Select Order_NO,Item_Code,Sum(QTy) as TotalQTY 
	FROM OrderDetails
	where qty&amp;gt;=2
	GROUP BY Order_NO,Item_Code
	Order By Order_NO Desc,Item_Code
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed450301286648-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed450301286648-19">
               19
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed450301286648-1">
               <span class="crayon-c">
                --Group By -&amp;gt; To display the data with group result.Here we can see we display all the AQggregate result by Item Name
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-2">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               ITEM_NAME,
               <span class="crayon-e ">
                Count
               </span>
               (*)
               <span class="crayon-h">
               </span>
               TotalRows,
               <span class="crayon-e ">
                AVG
               </span>
               (Price)
               <span class="crayon-h">
               </span>
               AVGPrice
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-3">
               <span class="crayon-h">
               </span>
               ,
               <span class="crayon-e ">
                MAX
               </span>
               (Price)
               <span class="crayon-h">
               </span>
               MAXPrice,
               <span class="crayon-e ">
                MIN
               </span>
               (Price)
               <span class="crayon-h">
               </span>
               MinPrice,
               <span class="crayon-e ">
                Sum
               </span>
               (price)
               <span class="crayon-h">
               </span>
               PriceTotal
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-5">
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                GROUP BY
               </span>
               <span class="crayon-h">
               </span>
               ITEM_NAME
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-8">
               <span class="crayon-c">
                -- Here this group by will combine all the same Order_No result and make the total or each order_NO
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-9">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Order_NO,
               <span class="crayon-e ">
                Sum
               </span>
               (QTy)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalQTY
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               qty
               <span class="crayon-o">
                &amp;
               </span>
               gt;=2
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                GROUP BY
               </span>
               <span class="crayon-h">
               </span>
               Order_NO
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-13">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-14">
               <span class="crayon-c">
                -- Here the Total will be created by order_No and Item_Code
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-15">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Order_NO,Item_Code,
               <span class="crayon-e ">
                Sum
               </span>
               (QTy)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalQTY
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               qty
               <span class="crayon-o">
                &amp;
               </span>
               gt;=2
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed450301286648-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                GROUP BY
               </span>
               <span class="crayon-h">
               </span>
               Order_NO,Item_Code
              </div>
              <div class="crayon-line" id="crayon-576865bbed450301286648-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Order
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                By
               </span>
               <span class="crayon-h">
               </span>
               Order_NO
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Desc
               </span>
               ,Item_Code
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0045 seconds] -->
       <p>
        Group By &amp; Having 子句
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed457158261311" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --Group By Clause -- here this will display all the Order_no 
Select Order_NO,Sum(QTy) as TotalQTY 
	FROM OrderDetails
	GROUP BY Order_NO

-- Having Clause-- This will avoid the the sum(qty) less then 4	
Select Order_NO,Sum(QTy) as TotalQTY 
	FROM OrderDetails
	GROUP BY Order_NO
	HAVING Sum(QTy) &amp;gt;4
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed457158261311-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed457158261311-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed457158261311-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed457158261311-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed457158261311-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed457158261311-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed457158261311-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed457158261311-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed457158261311-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed457158261311-10">
               10
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed457158261311-1">
               <span class="crayon-c">
                --Group By Clause -- here this will display all the Order_no
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed457158261311-2">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Order_NO,
               <span class="crayon-e ">
                Sum
               </span>
               (QTy)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalQTY
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed457158261311-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed457158261311-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                GROUP BY
               </span>
               <span class="crayon-h">
               </span>
               Order_NO
              </div>
              <div class="crayon-line" id="crayon-576865bbed457158261311-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed457158261311-6">
               <span class="crayon-c">
                -- Having Clause-- This will avoid the the sum(qty) less then 4
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed457158261311-7">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Order_NO,
               <span class="crayon-e ">
                Sum
               </span>
               (QTy)
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalQTY
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed457158261311-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
              </div>
              <div class="crayon-line" id="crayon-576865bbed457158261311-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                GROUP BY
               </span>
               <span class="crayon-h">
               </span>
               Order_NO
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed457158261311-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                HAVING
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                Sum
               </span>
               (QTy)
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;gt;
               </span>
               4
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0027 seconds] -->
       <p>
       </p>
       <p>
        <strong>
         <img src="http://dataunion.org/wp-content/uploads/2015/04/57e79553e7ba3aba9f9889c865ef68f8.jpg"/>
        </strong>
       </p>
       <p>
       </p>
       <h2>
        8、子查询
       </h2>
       <p>
        子查询一般出现在where内连接查询和嵌套查询中，select、update和delete语句中均可以使用。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed45d799118630" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --Sub Query -- Here we used the Sub query in where clause to get all the Item_Code where the price&amp;gt;40 now this sub 
--query reslut we used in our main query to filter all the records which Item_code from Subquery result
SELECT * FROM ItemMasters 
		 WHERE Item_Code IN 
		(SELECT Item_Code FROM ItemMasters WHERE price &amp;gt; 40) 

-- Sub Query with Insert Statement
INSERT INTO ItemMasters           ([Item_Code] ,[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
           ,[IN_USR_ID],[UP_DATE] ,[UP_USR_ID])
    Select 'Item006'
           ,Item_Name,Price+4,TAX1,Discount,Description
           ,GetDate(),'SHANU',GetDate(),'SHANU'
           from ItemMasters
           where Item_code='Item002'       

--After insert we can see the result as 
        Select * from ItemMasters
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed45d799118630-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed45d799118630-17">
               17
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed45d799118630-1">
               <span class="crayon-c">
                --Sub Query -- Here we used the Sub query in where clause to get all the Item_Code where the price&amp;gt;40 now this sub
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-2">
               <span class="crayon-c">
                --query reslut we used in our main query to filter all the records which Item_code from Subquery result
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-3">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                IN
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-5">
               <span class="crayon-h">
               </span>
               (
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;gt;
               </span>
               <span class="crayon-h">
               </span>
               40)
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-6">
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-7">
               <span class="crayon-c">
                -- Sub Query with Insert Statement
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-8">
               <span class="crayon-st">
                INSERT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INTO
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               ([Item_Code]
               <span class="crayon-h">
               </span>
               ,[Item_Name],[Price],[TAX1],[Discount],[Description],[IN_DATE]
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-9">
               <span class="crayon-h">
               </span>
               ,[IN_USR_ID],[UP_DATE]
               <span class="crayon-h">
               </span>
               ,[UP_USR_ID])
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'Item006'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-11">
               <span class="crayon-h">
               </span>
               ,Item_Name,Price
               <span class="crayon-o">
                +
               </span>
               4,TAX1,Discount,Description
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-12">
               <span class="crayon-h">
               </span>
               ,GetDate(),
               <span class="crayon-s">
                'SHANU'
               </span>
               ,GetDate(),
               <span class="crayon-s">
                'SHANU'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               Item_code=
               <span class="crayon-s">
                'Item002'
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-15">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed45d799118630-16">
               <span class="crayon-c">
                --After insert we can see the result as
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed45d799118630-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0042 seconds] -->
       <p>
       </p>
       <h2>
        9、连接查询
       </h2>
       <p>
        到目前为止我们接触了不少单表的查询语句，现在我们来使用连接查询获取多个表的数据。
       </p>
       <p>
        简单的join语句：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed465880615175" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --Now we have used the simple join with out any condition this will display all the
-- records with duplicate data to avaoid this we see our next example with condition
SELECT * FROM Ordermasters,OrderDetails
-- Simple Join with Condition  now here we can see the duplicate records now has been avoided by using the where checing with both table primaryKey field
SELECT * 
		FROM
		Ordermasters as M, OrderDetails as D
		where M.Order_NO=D.Order_NO
		and M.Order_NO='Ord_001'

-- Now to make more better understanding we need to select the need fields from both 
--table insted of displaying all column.
SELECT M.order_NO,M.Table_ID,D.Order_detail_no,Item_code,Notes,Qty
				FROM 
				Ordermasters as M, OrderDetails as D 
				where M.Order_NO=D.Order_NO                  
 -- Now lets Join 3 table
 SELECT	 M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,
                I.Price*D.Qty as TotalPrice
				FROM 
				Ordermasters as M, OrderDetails as D,ItemMasters as I 
				where 
				M.Order_NO=D.Order_NO AND D.Item_Code=I.Item_Code
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed465880615175-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed465880615175-23">
               23
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed465880615175-1">
               <span class="crayon-c">
                --Now we have used the simple join with out any condition this will display all the
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-2">
               <span class="crayon-c">
                -- records with duplicate data to avaoid this we see our next example with condition
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-3">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               Ordermasters,OrderDetails
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-4">
               <span class="crayon-c">
                -- Simple Join with Condition  now here we can see the duplicate records now has been avoided by using the where checing with both table primaryKey field
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-5">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-7">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M,
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                and
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO=
               <span class="crayon-s">
                'Ord_001'
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-10">
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-11">
               <span class="crayon-c">
                -- Now to make more better understanding we need to select the need fields from both
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-12">
               <span class="crayon-c">
                --table insted of displaying all column.
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-13">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,Item_code,Notes,Qty
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-15">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M,
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                -- Now lets Join 3 table
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-19">
               <span class="crayon-h">
               </span>
               I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-21">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M,
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D,ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed465880615175-22">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed465880615175-23">
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AND
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0062 seconds] -->
       <p>
       </p>
       <p>
        <strong>
         Inner Join,Left Outer Join,Right Outer Join and Full outer Join
        </strong>
       </p>
       <p>
       </p>
       <p>
        下面是各种类型的连接查询代码：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed46b341811634" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --INNER JOIN 
--This will display the records which in both table Satisfy here i have used Like in where class which display the 
SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price*D.Qty as TotalPrice
		FROM 
		Ordermasters as M Inner JOIN OrderDetails as D 
		ON M.Order_NO=D.Order_NO
		INNER JOIN 	ItemMasters as I 
		ON   D.Item_Code=I.Item_Code
		WHERE
		M.Table_ID like 'T%'
--LEFT OUTER JOIN 
--This will display the records which Left side table Satisfy
 SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price*D.Qty as TotalPrice
		FROM 
		Ordermasters as M LEFT OUTER JOIN OrderDetails as D 
		ON M.Order_NO=D.Order_NO
		LEFT OUTER JOIN 	ItemMasters as I 
		ON   D.Item_Code=I.Item_Code
		WHERE
		M.Table_ID like 'T%'
--RIGHT OUTER JOIN 
--This will display the records which Left side table Satisfy
 SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price*D.Qty as TotalPrice
		FROM 
		Ordermasters as M RIGHT OUTER JOIN OrderDetails as D 
		ON M.Order_NO=D.Order_NO
		RIGHT OUTER JOIN 	ItemMasters as I 
		ON   D.Item_Code=I.Item_Code
		WHERE
		M.Table_ID like 'T%'

--FULL OUTER JOIN 
--This will display the records which Left side table Satisfy
 SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price*D.Qty as TotalPrice
		FROM 
		Ordermasters as M FULL OUTER JOIN OrderDetails as D 
		ON M.Order_NO=D.Order_NO
		FULL OUTER JOIN 	ItemMasters as I 
		ON   D.Item_Code=I.Item_Code
		WHERE
		M.Table_ID like 'T%'
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-32">
               32
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-33">
               33
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-34">
               34
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-35">
               35
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-36">
               36
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-37">
               37
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-38">
               38
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-39">
               39
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed46b341811634-40">
               40
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed46b341811634-41">
               41
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed46b341811634-1">
               <span class="crayon-c">
                --INNER JOIN
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-2">
               <span class="crayon-c">
                --This will display the records which in both table Satisfy here i have used Like in where class which display the
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-3">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-5">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                Inner JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INNER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-10">
               <span class="crayon-h">
               </span>
               M.Table_ID
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                like
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'T%'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-11">
               <span class="crayon-c">
                --LEFT OUTER JOIN
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-12">
               <span class="crayon-c">
                --This will display the records which Left side table Satisfy
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-15">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                LEFT OUTER JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                LEFT OUTER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-20">
               <span class="crayon-h">
               </span>
               M.Table_ID
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                like
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'T%'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-21">
               <span class="crayon-c">
                --RIGHT OUTER JOIN
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-22">
               <span class="crayon-c">
                --This will display the records which Left side table Satisfy
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-23">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-24">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-25">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                RIGHT OUTER JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-26">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-27">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                RIGHT OUTER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-28">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-29">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-30">
               <span class="crayon-h">
               </span>
               M.Table_ID
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                like
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'T%'
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-31">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-32">
               <span class="crayon-c">
                --FULL OUTER JOIN
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-33">
               <span class="crayon-c">
                --This will display the records which Left side table Satisfy
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-34">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-35">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-36">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FULL OUTER JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-37">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-38">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FULL OUTER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-39">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed46b341811634-40">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed46b341811634-41">
               <span class="crayon-h">
               </span>
               M.Table_ID
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                like
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'T%'
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0162 seconds] -->
       <p>
       </p>
       <h2>
        10、Union合并查询
       </h2>
       <p>
        Union查询可以把多张表的数据合并起来，Union只会把唯一的数据查询出来，而Union ALL则会把重复的数据也查询出来。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed473039879661" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Select column1,Colum2 from Table1
Union
Select Column1,Column2 from Table2

Select column1,Colum2 from Table1
Union All
Select Column1,Column2 from Table2
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed473039879661-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed473039879661-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed473039879661-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed473039879661-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed473039879661-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed473039879661-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed473039879661-7">
               7
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed473039879661-1">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               column1,Colum2
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               Table1
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed473039879661-2">
               <span class="crayon-st">
                Union
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed473039879661-3">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Column1,Column2
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               Table2
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed473039879661-4">
              </div>
              <div class="crayon-line" id="crayon-576865bbed473039879661-5">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               column1,Colum2
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               Table1
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed473039879661-6">
               <span class="crayon-st">
                Union
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                All
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed473039879661-7">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               Column1,Column2
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               Table2
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0019 seconds] -->
       <p>
        具体的例子如下：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed479754345758" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          --Select with different where condition which display the result as 2 Table result
select Item_Code,Item_Name,Price,Description FROM ItemMasters where price &amp;lt;=44
select Item_Code,Item_Name,Price,Description FROM ItemMasters where price &amp;gt;44

-- Union with same table but with different where condition now which result as one table which combine both the result.
select Item_Code,Item_Name,Price,Description FROM ItemMasters where price &amp;lt;=44
UNION
select Item_Code,Item_Name,Price,Description FROM ItemMasters where price &amp;gt;44

-- Union ALL with Join sample
 SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price*D.Qty as TotalPrice
	FROM 
		Ordermasters as M (NOLOCK)   Inner JOIN OrderDetails as D  
		ON M.Order_NO=D.Order_NO INNER JOIN 	ItemMasters as I 
		ON   D.Item_Code=I.Item_Code WHERE		I.Price &amp;lt;=44		
Union ALL
 SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price*D.Qty as TotalPrice
	FROM 
		Ordermasters as M (NOLOCK)   Inner JOIN OrderDetails as D
		ON M.Order_NO=D.Order_NO	INNER JOIN 	ItemMasters as I
		ON   D.Item_Code=I.Item_Code	WHERE	I.Price&amp;gt;44
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed479754345758-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed479754345758-21">
               21
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed479754345758-1">
               <span class="crayon-c">
                --Select with different where condition which display the result as 2 Table result
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-2">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               Item_Code,Item_Name,Price,Description
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;lt;
               </span>
               =44
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-3">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               Item_Code,Item_Name,Price,Description
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;gt;
               </span>
               44
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-4">
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-5">
               <span class="crayon-c">
                -- Union with same table but with different where condition now which result as one table which combine both the result.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-6">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               Item_Code,Item_Name,Price,Description
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;lt;
               </span>
               =44
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-7">
               <span class="crayon-st">
                UNION
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-8">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               Item_Code,Item_Name,Price,Description
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;gt;
               </span>
               44
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-9">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-10">
               <span class="crayon-c">
                -- Union ALL with Join sample
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-13">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               (NOLOCK)
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                Inner JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INNER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               I.Price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;lt;
               </span>
               =44
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-16">
               <span class="crayon-st">
                Union
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                ALL
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-19">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               (NOLOCK)
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                Inner JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed479754345758-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INNER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
              </div>
              <div class="crayon-line" id="crayon-576865bbed479754345758-21">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               I.Price
               <span class="crayon-o">
                &amp;
               </span>
               gt;44
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0096 seconds] -->
       <p>
       </p>
       <h2>
        11、公用表表达式（CTE）——With语句
       </h2>
       <p>
        CTE可以看作是一个临时的结果集，可以在接下来的一个SELECT,INSERT,UPDATE,DELETE,MERGE语句中被多次引用。使用公用表达式可以让语句更加清晰简练。
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed480454727270" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          declare @sDate datetime,
        @eDate datetime;

select  @sDate = getdate()-5,
        @eDate = getdate()+16;
--select @sDate StartDate,@eDate EndDate
;with cte as
   (
      select @sDate StartDate,'W'+convert(varchar(2),
            DATEPART( wk, @sDate))+'('+convert(varchar(2),@sDate,106)+')' as 'SDT'     
  union all
       select  dateadd(DAY, 1, StartDate) ,
              'W'+convert(varchar(2),DATEPART( wk, StartDate))+'('+convert(varchar(2),
               dateadd(DAY, 1, StartDate),106)+')' as 'SDT'   
  FROM  cte
  WHERE dateadd(DAY, 1, StartDate)&amp;lt;=  @eDate 
    )
select * from cte
option (maxrecursion 0)
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed480454727270-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed480454727270-19">
               19
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed480454727270-1">
               <span class="crayon-st">
                declare
               </span>
               <span class="crayon-h">
               </span>
               @sDate
               <span class="crayon-h">
               </span>
               datetime,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-2">
               <span class="crayon-h">
               </span>
               @eDate
               <span class="crayon-h">
               </span>
               datetime;
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-3">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-4">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               @sDate
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               getdate()-5,
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-5">
               <span class="crayon-h">
               </span>
               @eDate
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               getdate()+16;
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-6">
               <span class="crayon-c">
                --select @sDate StartDate,@eDate EndDate
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-7">
               ;
               <span class="crayon-st">
                with
               </span>
               <span class="crayon-h">
               </span>
               cte
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-8">
               <span class="crayon-h">
               </span>
               (
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               @sDate
               <span class="crayon-h">
               </span>
               StartDate,
               <span class="crayon-s">
                'W'
               </span>
               +
               <span class="crayon-e ">
                convert
               </span>
               (
               <span class="crayon-t">
                varchar
               </span>
               (2),
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-10">
               <span class="crayon-h">
               </span>
               DATEPART(
               <span class="crayon-h">
               </span>
               wk,
               <span class="crayon-h">
               </span>
               @sDate))+
               <span class="crayon-s">
                '('
               </span>
               +
               <span class="crayon-e ">
                convert
               </span>
               (
               <span class="crayon-t">
                varchar
               </span>
               (2),@sDate,106)+
               <span class="crayon-s">
                ')'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'SDT'
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                union
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                all
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               dateadd(
               <span class="crayon-r">
                DAY
               </span>
               ,
               <span class="crayon-h">
               </span>
               1,
               <span class="crayon-h">
               </span>
               StartDate)
               <span class="crayon-h">
               </span>
               ,
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'W'
               </span>
               +
               <span class="crayon-e ">
                convert
               </span>
               (
               <span class="crayon-t">
                varchar
               </span>
               (2),DATEPART(
               <span class="crayon-h">
               </span>
               wk,
               <span class="crayon-h">
               </span>
               StartDate))+
               <span class="crayon-s">
                '('
               </span>
               +
               <span class="crayon-e ">
                convert
               </span>
               (
               <span class="crayon-t">
                varchar
               </span>
               (2),
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-14">
               <span class="crayon-h">
               </span>
               dateadd(
               <span class="crayon-r">
                DAY
               </span>
               ,
               <span class="crayon-h">
               </span>
               1,
               <span class="crayon-h">
               </span>
               StartDate),106)+
               <span class="crayon-s">
                ')'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'SDT'
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               cte
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               dateadd(
               <span class="crayon-r">
                DAY
               </span>
               ,
               <span class="crayon-h">
               </span>
               1,
               <span class="crayon-h">
               </span>
               StartDate)
               <span class="crayon-h">
                &amp;lt;
               </span>
               =
               <span class="crayon-h">
               </span>
               @eDate
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-17">
               <span class="crayon-h">
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed480454727270-18">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               cte
              </div>
              <div class="crayon-line" id="crayon-576865bbed480454727270-19">
               <span class="crayon-r">
                option
               </span>
               <span class="crayon-h">
               </span>
               (maxrecursion
               <span class="crayon-h">
               </span>
               0)
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0058 seconds] -->
       <p>
       </p>
       <h2>
        12、视图
       </h2>
       <p>
        很多人对视图View感到很沮丧，因为它看起来跟select语句没什么区别。在视图中我们同样可以使用select查询语句，但是视图对我们来说依然非常重要。
       </p>
       <p>
        假设我们要联合查询4张表中的20几个字段，那么这个select查询语句会非常复杂。但是这样的语句我们在很多地方都需要用到，如果将它编写成视图，那么使用起来会方便很多。利用视图查询有以下几个优点：
       </p>
       <ul>
        <li>
         一定程度上提高查询速度
        </li>
        <li>
         可以对一些字段根据不同的权限进行屏蔽，因此提高了安全性
        </li>
        <li>
         对多表的连接查询会非常方便
        </li>
       </ul>
       <p>
        下面是一个视图的代码例子：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed487384310474" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE 
VIEW viewname
AS
Select ColumNames from yourTable

Example : 
-- Here we create view for our Union ALL example
Create 
VIEW myUnionVIEW
AS
 SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,
        I.Price*D.Qty as TotalPrice
	    FROM 
		  Ordermasters as M  Inner JOIN OrderDetails as D 
		  ON M.Order_NO=D.Order_NO INNER JOIN ItemMasters as I 
		  ON   D.Item_Code=I.Item_Code WHERE	I.Price &amp;lt;=44		
Union ALL
 SELECT M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,
        I.Price*D.Qty as TotalPrice
	    FROM 
		  Ordermasters as M  Inner JOIN OrderDetails as D 
		  ON M.Order_NO=D.Order_NO INNER JOIN ItemMasters as I 
		  ON   D.Item_Code=I.Item_Code	WHERE	I.Price&amp;gt;44

-- View Select query
Select * from myUnionVIEW
-- We can also use the View to display with where condition and with selected fields 
Select order_Detail_NO,Table_ID,Item_Name,Price from myUnionVIEW where price &amp;gt;40
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed487384310474-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed487384310474-28">
               28
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed487384310474-1">
               <span class="crayon-st">
                CREATE
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-2">
               <span class="crayon-r">
                VIEW
               </span>
               <span class="crayon-h">
               </span>
               viewname
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-3">
               <span class="crayon-r">
                AS
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-4">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               ColumNames
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               yourTable
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-6">
               Example
               <span class="crayon-h">
               </span>
               :
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-7">
               <span class="crayon-c">
                -- Here we create view for our Union ALL example
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-8">
               <span class="crayon-st">
                Create
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-9">
               <span class="crayon-r">
                VIEW
               </span>
               <span class="crayon-h">
               </span>
               myUnionVIEW
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-10">
               <span class="crayon-r">
                AS
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-12">
               <span class="crayon-h">
               </span>
               I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-14">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                Inner JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INNER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               I.Price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;lt;
               </span>
               =44
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-17">
               <span class="crayon-st">
                Union
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                ALL
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               M.order_NO,M.Table_ID,D.Order_detail_no,I.Item_Name,D.Notes,D.Qty,I.Price,
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-19">
               <span class="crayon-h">
               </span>
               I.Price
               <span class="crayon-o">
                *
               </span>
               D.Qty
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotalPrice
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-21">
               <span class="crayon-h">
               </span>
               Ordermasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               M
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                Inner JOIN
               </span>
               <span class="crayon-h">
               </span>
               OrderDetails
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               D
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-22">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               M.Order_NO
               <span class="crayon-o">
                =
               </span>
               D.Order_NO
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                INNER JOIN
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               I
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-23">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ON
               </span>
               <span class="crayon-h">
               </span>
               D.Item_Code
               <span class="crayon-o">
                =
               </span>
               I.Item_Code
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                WHERE
               </span>
               <span class="crayon-h">
               </span>
               I.Price
               <span class="crayon-o">
                &amp;
               </span>
               gt;44
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-24">
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-25">
               <span class="crayon-c">
                -- View Select query
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-26">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               myUnionVIEW
              </div>
              <div class="crayon-line" id="crayon-576865bbed487384310474-27">
               <span class="crayon-c">
                -- We can also use the View to display with where condition and with selected fields
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed487384310474-28">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               order_Detail_NO,Table_ID,Item_Name,Price
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               myUnionVIEW
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                where
               </span>
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-h">
                &amp;gt;
               </span>
               40
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0412 seconds] -->
       <p>
       </p>
       <h2>
        13、Pivot行转列
       </h2>
       <p>
        Pivot可以帮助你实现数据行转换成数据列，具体用法如下：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed48d431785998" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- Simple Pivot Example 
SELECT *  FROM ItemMasters 
PIVOT(SUM(Price)       
 FOR ITEM_NAME IN ([Chiken Burger], Coffee,Coke)) AS PVTTable

-- Pivot with detail example
SELECT *
FROM (
    SELECT 
       ITEM_NAME, 
        price as TotAmount 
    FROM ItemMasters

) as s
PIVOT
(
    SUM(TotAmount)
    FOR [ITEM_NAME] IN ([Chiken Burger], [Coffee],[Coke])
)AS MyPivot
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed48d431785998-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed48d431785998-19">
               19
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed48d431785998-1">
               <span class="crayon-c">
                -- Simple Pivot Example
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-2">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               *
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-3">
               PIVOT(
               <span class="crayon-e ">
                SUM
               </span>
               (Price)
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FOR
               </span>
               <span class="crayon-h">
               </span>
               ITEM_NAME
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                IN
               </span>
               <span class="crayon-h">
               </span>
               ([Chiken
               <span class="crayon-h">
               </span>
               Burger],
               <span class="crayon-h">
               </span>
               Coffee,Coke))
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               PVTTable
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-6">
               <span class="crayon-c">
                -- Pivot with detail example
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-7">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               *
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-8">
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               (
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-10">
               <span class="crayon-h">
               </span>
               ITEM_NAME,
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-11">
               <span class="crayon-h">
               </span>
               price
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               TotAmount
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-13">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-14">
               )
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                as
               </span>
               <span class="crayon-h">
               </span>
               s
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-15">
               PIVOT
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-16">
               (
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                SUM
               </span>
               (TotAmount)
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed48d431785998-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FOR
               </span>
               <span class="crayon-h">
               </span>
               [ITEM_NAME]
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                IN
               </span>
               <span class="crayon-h">
               </span>
               ([Chiken
               <span class="crayon-h">
               </span>
               Burger],
               <span class="crayon-h">
               </span>
               [Coffee],[Coke])
              </div>
              <div class="crayon-line" id="crayon-576865bbed48d431785998-19">
               )
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               MyPivot
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0136 seconds] -->
       <p>
       </p>
       <h2>
        14、存储过程
       </h2>
       <p>
        我经常看到有人提问如何在SQL Server中编写多条查询的SQL语句，然后将它们使用到C#程序中去。存储过程就可以完成这样的功能，存储过程可以将多个SQL查询聚集在一起，创建存储过程的基本结构是这样的：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed495595444073" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          CREATE PROCEDURE [ProcedureName]                                              

AS                                                                
BEGIN
-- Select or Update or Insert query.
END

To execute SP we use
exec ProcedureName
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed495595444073-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed495595444073-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed495595444073-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed495595444073-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed495595444073-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed495595444073-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed495595444073-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed495595444073-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed495595444073-9">
               9
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed495595444073-1">
               <span class="crayon-st">
                CREATE
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                PROCEDURE
               </span>
               <span class="crayon-h">
               </span>
               [ProcedureName]
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed495595444073-2">
              </div>
              <div class="crayon-line" id="crayon-576865bbed495595444073-3">
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed495595444073-4">
               <span class="crayon-st">
                BEGIN
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed495595444073-5">
               <span class="crayon-c">
                -- Select or Update or Insert query.
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed495595444073-6">
               <span class="crayon-st">
                END
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed495595444073-7">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed495595444073-8">
               <span class="crayon-r">
                To
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                execute
               </span>
               <span class="crayon-h">
               </span>
               SP
               <span class="crayon-h">
               </span>
               we
               <span class="crayon-h">
               </span>
               use
              </div>
              <div class="crayon-line" id="crayon-576865bbed495595444073-9">
               exec
               <span class="crayon-h">
               </span>
               ProcedureName
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0017 seconds] -->
       <p>
        创建一个没有参数的存储过程：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed49b145763602" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- =============================================                                                                
-- Author      : Shanu                                                                
-- Create date : 2014-09-15                                                                
-- Description : To Display Pivot Data                                                        
-- Latest                                                                
-- Modifier    : Shanu                                                                
-- Modify date : 2014-09-15                                                                 
-- =============================================                                                                
-- exec USP_SelectPivot                                 
-- =============================================                                                           
Create PROCEDURE [dbo].[USP_SelectPivot]      
AS                                                                
BEGIN                                                 
   DECLARE @MyColumns AS NVARCHAR(MAX),
    @SQLquery  AS NVARCHAR(MAX)
-- here first we get all the ItemName which should be display in Columns we use this in our necxt pivot query
select @MyColumns = STUFF((SELECT ',' + QUOTENAME(Item_NAME) 
                    FROM ItemMasters
                    GROUP BY Item_NAME
                    ORDER BY Item_NAME
            FOR XML PATH(''), TYPE
            ).value('.', 'NVARCHAR(MAX)') 
        ,1,1,'')
-- here we use the above all Item name to disoplay its price as column and row display
set @SQLquery = N'SELECT ' + @MyColumns + N' from 
             (
                 SELECT 
       ITEM_NAME, 
        price as TotAmount 
    FROM ItemMasters
            ) x
            pivot 
            (
                 SUM(TotAmount)
                for ITEM_NAME in (' + @MyColumns + N')
            ) p '

exec sp_executesql @SQLquery;           

   RETURN                                              
    END
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-32">
               32
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-33">
               33
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-34">
               34
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-35">
               35
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-36">
               36
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-37">
               37
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-38">
               38
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-39">
               39
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed49b145763602-40">
               40
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed49b145763602-41">
               41
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed49b145763602-1">
               <span class="crayon-c">
                -- =============================================
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-2">
               <span class="crayon-c">
                -- Author      : Shanu
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-3">
               <span class="crayon-c">
                -- Create date : 2014-09-15
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-4">
               <span class="crayon-c">
                -- Description : To Display Pivot Data
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-5">
               <span class="crayon-c">
                -- Latest
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-6">
               <span class="crayon-c">
                -- Modifier    : Shanu
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-7">
               <span class="crayon-c">
                -- Modify date : 2014-09-15
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-8">
               <span class="crayon-c">
                -- =============================================
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-9">
               <span class="crayon-c">
                -- exec USP_SelectPivot
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-10">
               <span class="crayon-c">
                -- =============================================
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-11">
               <span class="crayon-st">
                Create
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                PROCEDURE
               </span>
               <span class="crayon-h">
               </span>
               [dbo].[USP_SelectPivot]
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-12">
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-13">
               <span class="crayon-st">
                BEGIN
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                DECLARE
               </span>
               <span class="crayon-h">
               </span>
               @MyColumns
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               NVARCHAR(
               <span class="crayon-e ">
                MAX
               </span>
               ),
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-15">
               <span class="crayon-h">
               </span>
               @SQLquery
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               NVARCHAR(
               <span class="crayon-e ">
                MAX
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-16">
               <span class="crayon-c">
                -- here first we get all the ItemName which should be display in Columns we use this in our necxt pivot query
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-17">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               @MyColumns
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               STUFF((
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ','
               </span>
               <span class="crayon-h">
               </span>
               +
               <span class="crayon-h">
               </span>
               QUOTENAME(Item_NAME)
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FROM
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                GROUP BY
               </span>
               <span class="crayon-h">
               </span>
               Item_NAME
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                ORDER
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                BY
               </span>
               <span class="crayon-h">
               </span>
               Item_NAME
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-21">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                FOR
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                XML
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                PATH
               </span>
               (
               <span class="crayon-s">
                ''
               </span>
               ),
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                TYPE
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-22">
               <span class="crayon-h">
               </span>
               ).
               <span class="crayon-r">
                value
               </span>
               (
               <span class="crayon-s">
                '.'
               </span>
               ,
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                'NVARCHAR(MAX)'
               </span>
               )
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-23">
               <span class="crayon-h">
               </span>
               ,1,1,
               <span class="crayon-s">
                ''
               </span>
               )
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-24">
               <span class="crayon-c">
                -- here we use the above all Item name to disoplay its price as column and row display
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-25">
               <span class="crayon-st">
                set
               </span>
               <span class="crayon-h">
               </span>
               @SQLquery
               <span class="crayon-h">
               </span>
               =
               <span class="crayon-h">
               </span>
               N
               <span class="crayon-s">
                'SELECT '
               </span>
               <span class="crayon-h">
               </span>
               +
               <span class="crayon-h">
               </span>
               @MyColumns
               <span class="crayon-h">
               </span>
               +
               <span class="crayon-h">
               </span>
               N
               <span class="crayon-s">
                ' from
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-26">
               <span class="crayon-s">
                (
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-27">
               <span class="crayon-s">
                SELECT
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-28">
               <span class="crayon-s">
                ITEM_NAME,
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-29">
               <span class="crayon-s">
                price as TotAmount
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-30">
               <span class="crayon-s">
                FROM ItemMasters
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-31">
               <span class="crayon-s">
                ) x
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-32">
               <span class="crayon-s">
                pivot
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-33">
               <span class="crayon-s">
                (
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-34">
               <span class="crayon-s">
                SUM(TotAmount)
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-35">
               <span class="crayon-s">
                for ITEM_NAME in ('
               </span>
               <span class="crayon-h">
               </span>
               +
               <span class="crayon-h">
               </span>
               @MyColumns
               <span class="crayon-h">
               </span>
               +
               <span class="crayon-h">
               </span>
               N
               <span class="crayon-s">
                ')
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-36">
               <span class="crayon-s">
                ) p '
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-37">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-38">
               exec
               <span class="crayon-h">
               </span>
               sp_executesql
               <span class="crayon-h">
               </span>
               @SQLquery;
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-39">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed49b145763602-40">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                RETURN
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed49b145763602-41">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                END
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0253 seconds] -->
       <p>
       </p>
       <h2>
        15、函数Function
       </h2>
       <p>
        之前我们介绍了MAX(),SUM(), GetDate()等最基本的SQL函数，现在我们来看看如何创建自定义SQL函数。创建函数的格式如下：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed4a3833639846" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          Create Function functionName
As
Begin
END
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed4a3833639846-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a3833639846-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a3833639846-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a3833639846-4">
               4
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed4a3833639846-1">
               <span class="crayon-st">
                Create
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                Function
               </span>
               <span class="crayon-h">
               </span>
               functionName
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a3833639846-2">
               <span class="crayon-r">
                As
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a3833639846-3">
               <span class="crayon-st">
                Begin
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a3833639846-4">
               <span class="crayon-st">
                END
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0010 seconds] -->
       <p>
        下面是一个简单的函数示例：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed4a8432658971" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- =============================================                                                                
-- Author      : Shanu                                                                
-- Create date : 2014-09-15                                                                
-- Description : To Display Pivot Data                                                        
-- Latest                                                                
-- Modifier    : Shanu                                                                
-- Modify date : 2014-09-15                                                                 

Alter FUNCTION [dbo].[ufnSelectitemMaster]()
RETURNS int 
AS 
-- Returns total Row count of Item Master.

BEGIN
  DECLARE @RowsCount AS int;

Select @RowsCount= count(*)+1 from ItemMasters
 RETURN @RowsCount;

END

-- to View Function we use select and fucntion Name
select [dbo].[ufnSelectitemMaster]()
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4a8432658971-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4a8432658971-23">
               23
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-1">
               <span class="crayon-c">
                -- =============================================
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-2">
               <span class="crayon-c">
                -- Author      : Shanu
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-3">
               <span class="crayon-c">
                -- Create date : 2014-09-15
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-4">
               <span class="crayon-c">
                -- Description : To Display Pivot Data
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-5">
               <span class="crayon-c">
                -- Latest
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-6">
               <span class="crayon-c">
                -- Modifier    : Shanu
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-7">
               <span class="crayon-c">
                -- Modify date : 2014-09-15
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-8">
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-9">
               <span class="crayon-st">
                Alter
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                FUNCTION
               </span>
               <span class="crayon-h">
               </span>
               [dbo].[ufnSelectitemMaster]()
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-10">
               <span class="crayon-r">
                RETURNS
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-11">
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-12">
               <span class="crayon-c">
                -- Returns total Row count of Item Master.
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-13">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-14">
               <span class="crayon-st">
                BEGIN
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                DECLARE
               </span>
               <span class="crayon-h">
               </span>
               @RowsCount
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               ;
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-16">
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-17">
               <span class="crayon-st">
                Select
               </span>
               <span class="crayon-h">
               </span>
               @RowsCount=
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                count
               </span>
               (*)+1
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                from
               </span>
               <span class="crayon-h">
               </span>
               ItemMasters
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                RETURN
               </span>
               <span class="crayon-h">
               </span>
               @RowsCount;
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-19">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-20">
               <span class="crayon-st">
                END
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-21">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4a8432658971-22">
               <span class="crayon-c">
                -- to View Function we use select and fucntion Name
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4a8432658971-23">
               <span class="crayon-st">
                select
               </span>
               <span class="crayon-h">
               </span>
               [dbo].[ufnSelectitemMaster]()
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0123 seconds] -->
       <p>
        下面的一个函数可以实现从给定的日期中得到当前月的最后一天：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-576865bbed4af684528493" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <span class="crayon-language">
           PgSQL
          </span>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          -- =============================================                                                                
-- Author      : Shanu                                                                
-- Create date : 2014-09-15                                                                
-- Description : To Display Pivot Data                                                        
-- Latest                                                                
-- Modifier    : Shanu                                                                
-- Modify date : 2014-09-15    

ALTER FUNCTION [dbo].[ufn_LastDayOfMonth]
(
   @DATE NVARCHAR(10) 
)
RETURNS NVARCHAR(10)
AS
BEGIN
   RETURN CONVERT(NVARCHAR(10), DATEADD(D, -1, DATEADD(M, 1, CAST(SUBSTRING(@DATE,1,7) + '-01' AS DATETIME))), 120)
END
SELECT dbo.ufn_LastDayOfMonth('2014-09-01')AS LastDay
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-576865bbed4af684528493-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-576865bbed4af684528493-18">
               18
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-576865bbed4af684528493-1">
               <span class="crayon-c">
                -- =============================================
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-2">
               <span class="crayon-c">
                -- Author      : Shanu
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-3">
               <span class="crayon-c">
                -- Create date : 2014-09-15
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-4">
               <span class="crayon-c">
                -- Description : To Display Pivot Data
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-5">
               <span class="crayon-c">
                -- Latest
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-6">
               <span class="crayon-c">
                -- Modifier    : Shanu
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-7">
               <span class="crayon-c">
                -- Modify date : 2014-09-15
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-8">
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-9">
               <span class="crayon-st">
                ALTER
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                FUNCTION
               </span>
               <span class="crayon-h">
               </span>
               [dbo].[ufn_LastDayOfMonth]
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-10">
               (
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-11">
               <span class="crayon-h">
               </span>
               @
               <span class="crayon-t">
                DATE
               </span>
               <span class="crayon-h">
               </span>
               NVARCHAR(10)
               <span class="crayon-h">
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-12">
               )
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-13">
               <span class="crayon-r">
                RETURNS
               </span>
               <span class="crayon-h">
               </span>
               NVARCHAR(10)
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-14">
               <span class="crayon-r">
                AS
               </span>
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-15">
               <span class="crayon-st">
                BEGIN
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                RETURN
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                CONVERT
               </span>
               (NVARCHAR(10),
               <span class="crayon-h">
               </span>
               DATEADD(D,
               <span class="crayon-h">
               </span>
               -1,
               <span class="crayon-h">
               </span>
               DATEADD(M,
               <span class="crayon-h">
               </span>
               1,
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                CAST
               </span>
               (
               <span class="crayon-e ">
                SUBSTRING
               </span>
               (@
               <span class="crayon-t">
                DATE
               </span>
               ,1,7)
               <span class="crayon-h">
               </span>
               +
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                '-01'
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               DATETIME))),
               <span class="crayon-h">
               </span>
               120)
              </div>
              <div class="crayon-line" id="crayon-576865bbed4af684528493-17">
               <span class="crayon-st">
                END
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-576865bbed4af684528493-18">
               <span class="crayon-st">
                SELECT
               </span>
               <span class="crayon-h">
               </span>
               dbo.ufn_LastDayOfMonth(
               <span class="crayon-s">
                '2014-09-01'
               </span>
               )
               <span class="crayon-r">
                AS
               </span>
               <span class="crayon-h">
               </span>
               LastDay
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0102 seconds] -->
       <p>
        译文链接：
        <a href="http://www.codeceo.com/article/15-basic-sql-for-beginner.html" target="_blank">
         http://www.codeceo.com/article/15-basic-sql-for-beginner.html
        </a>
        <br/>
        英文原文：
        <a href="http://www.codeproject.com/Articles/818756/Basic-SQL-Queries-for-Beginners" target="_blank">
         Basic SQL Queries for Beginners
        </a>
        <br/>
        翻译作者：
        <a href="http://www.codeceo.com/" target="_blank">
         码农网
        </a>
        – 小峰
       </p>
       <p>
        文章出处：http://www.codeceo.com/article/15-basic-sql-for-beginner.html
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20037.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/07/t01cbbd7ae2c54cab40.png"/>
        </a>
        <a class="link" href="http://dataunion.org/20037.html" rel="bookmark" title="记一次苦逼的SQL查询优化">
         记一次苦逼的SQL查询优化
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/19122.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/06/t01c8e61852c2874d06-300x225.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/19122.html" rel="bookmark" title="淘宝数据库OceanBase SQL编译器源码阅读：生成逻辑计划">
         淘宝数据库OceanBase SQL编译器源码阅读：生成逻辑计划
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/17652.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/05/QQ截图20150530222020.png"/>
        </a>
        <a class="link" href="http://dataunion.org/17652.html" rel="bookmark" title="QueryBuilder ： 打造优雅的Linq To SQL动态查询">
         QueryBuilder ： 打造优雅的Linq To SQL动态查询
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/17919.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/05/QQ截图20150521172348-300x181.png"/>
        </a>
        <a class="link" href="http://dataunion.org/17919.html" rel="bookmark" title="Sql优化（一） Merge Join vs. Hash Join vs. Nested Loop">
         Sql优化（一） Merge Join vs. Hash Join vs. Nested Loop
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F15872.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/15872.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/15872.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>